package top.btcmarket.auth.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
//import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import top.btcmarket.auth.entity.Resources;
import top.btcmarket.auth.service.ResourcesService;

@Controller
@RequestMapping(value = "/resources")
public class ResourcesController {
  
    @Autowired
    ResourcesService resourcesService;  //Service which will do all data retrieval/manipulation work
    
    @RequestMapping(value = "/save", method = RequestMethod.POST)
    @ResponseBody
    public ResponseEntity<Resources> saveResource(@RequestBody Resources res) {
    	
    	if(res != null){
    		resourcesService.save(res);
    	}
        return new ResponseEntity<Resources>(res, HttpStatus.OK);
    }
    
    
    @RequestMapping(value = "/saveAll", method = RequestMethod.POST)
    @ResponseBody
    public ResponseEntity<?> saveResources(@RequestBody List<Resources> ress) {
    	
    	if(ress != null){
    		resourcesService.saveList(ress);
    	}
        return new ResponseEntity<String>("true", HttpStatus.OK);
    }
    
    
  
  
  
      
  
  
}